package com.zw.separate;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @Description 读写分离项目
 * @Author zw
 * @Date 2021/5/19 16:31
 * @Param
 * @Return
**/
@Slf4j
@SpringBootApplication
@ServletComponentScan
@EnableScheduling
@Configuration
public class Separate extends SpringBootServletInitializer {

	public static void main(String[] args) {
		// 测试接口 url
		SpringApplication app = new SpringApplication(Separate.class);
		Environment env = app.run(args).getEnvironment();
		log.info("查询所有用户（读-从库）: http://127.0.0.1"+":" + env.getProperty("server.port") + "/select");
		log.info("新增用户（写-主库）: http://127.0.0.1"+":" + env.getProperty("server.port") + "/add?username=test0520&password=test0520");
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(Separate.class);
	}
}
